﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BlackBoard
{
    public partial class BlackBoardForm : Form
    {
        public BlackBoardForm()
        {
            InitializeComponent();
        }

        // Important Points
        private Point startPoint = new Point(0, 0);
        private Point currentPoint = new Point(0, 0);
        private Point endPoint = new Point(0, 0);
        //Important Operate Colors
        private Color drawColor = Color.Black;
        private Color backGroundColor = Color.White;
        //Operate weight
        private int operateWeight = 2;
        //Operate Styles
        enum operateStyles { EraseLine, DrawLine };
        operateStyles operateStyle = operateStyles.EraseLine;
        //Public Properties        
        public Color DrawColor
        {
            get { return drawColor; }
            set { drawColor = value; }
        }
      

        //If user click button "Pen"
        private void btn_Pen_Click(object sender, EventArgs e)
        {
            operateStyle = operateStyles.DrawLine;
            operateWeight = 2;
            DrawColor = Color.Black;
        }
        //If user click button "Eraser"
        private void btn_Eraser_Click(object sender, EventArgs e)
        {
            operateStyle = operateStyles.EraseLine;
            operateWeight = 10;
            DrawColor = panel_Canvas.BackColor;
        }

        //Draw or delete lines based on the path the mouse move
        private void panel_Canvas_MouseMove(object sender, MouseEventArgs e)
        {
            Graphics g = panel_Canvas.CreateGraphics();
            Pen p = new Pen(DrawColor, operateWeight);

            currentPoint.X = e.X;
            currentPoint.Y = e.Y;

            if (e.Button == MouseButtons.Left)
            {                
                g.DrawLine(p, startPoint, currentPoint);
            }
            else if (e.Button == MouseButtons.Right)
            { }
            else
            { }
            startPoint.X = e.X;
            startPoint.Y = e.Y;
        }

        private void panel_Canvas_MouseClick(object sender, MouseEventArgs e)
        {
            startPoint.X = e.X;
            startPoint.Y = e.Y;
        }




    }
}
